/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package plures;

import java.util.ArrayList;
import util.Pair;

/**
 *
 * @author Guilherme
 */
public class Return
{
    private final byte[] data;
    private final ArrayList<Pair<Integer,Integer>> versionArray;
    private final int status;

    public Return(byte[] data, ArrayList<Pair<Integer, Integer>> versionArray, int status)
    {
        this.data = data != null ? data : new byte[0];
        this.versionArray = versionArray != null ? versionArray : new ArrayList<Pair<Integer, Integer>>();
        this.status = status;
    }

    public byte[] getData()
    {
        return data;
    }

    public ArrayList<Pair<Integer, Integer>> getVersionArray()
    {
        return versionArray;
    }

    public int getStatus()
    {
        return status;
    }
        
    public String toString()
    {
        String s = "";
        if (this.data != null || this.versionArray != null)
        {        
            s = new String(this.data);
            for(Pair p : this.versionArray)
            {
                s += p.toString() + "; ";
            }
        }
        s += this.status == 200 ? "[ OK ]" : "[ ERROR ]";
        return s;
    }
    
}
